package msg

// R 构建一条返回数据
func R(code int, varName string, data interface{}) map[string]interface{} {
	// map使用前需要先初始化
	var resp = make(map[string]interface{})
	var respData = make(map[string]interface{})
	respData[varName] = data
	resp["code"] = code
	resp["msg"] = GetErrorMsg(code)
	resp["data"] = respData
	return resp
}

// RS 构建多条返回数据
func RS(code int, dataMap map[string]interface{}) map[string]interface{} {
	// map使用前需要先初始化
	var resp = make(map[string]interface{})
	var respData = make(map[string]interface{})
	for varName, data := range dataMap {
		respData[varName] = data
	}
	resp["code"] = code
	resp["msg"] = GetErrorMsg(code)
	resp["data"] = respData
	return resp
}
